clear textprogressbar; clear;
%% Create session, Connect devices
[session, zi]=CreateSession;
spect = zi.spectrumModule();

%%
spect.setControl('grid_repetitions', 10);
spect.setParam('spectrum/frequencyspan', 200);
spect.setParam('grid/cols', 1024);

spect.reset();
% demods data
spect.subscribeChannel('0', 'sample.R.fft.abs.avg');
spect.subscribeChannel('1', 'sample.R.fft.abs.avg');
spect.subscribeChannel('3', 'sample.AuxIn0.fft.abs.avg');
% pids data 
% spect.subscribeChannel('0', 'stream/shift.val.fft.abs.avg', 'channel_name', 'pids');
spect_data= spect.run();
spect.unsubscribeChannel();

spect.addToSession('spect_data');
MeasurementSession.save( session.close() );

%%
figure('Name', 'Spectrum data');
sp = spect_data.getNodeData('0',  'sample.R.fft.abs.avg');
semilogy(sp.freq, sp.value)